package com.ponhu.ea2.stockcenter.provider.support.exception;

import lombok.Data;
import lombok.experimental.Accessors;
import com.ponhu.ea2.stockcenter.enums.ResponseCodeEnum;

@Data
@Accessors(chain = true)
public class StockRuntimeException extends RuntimeException {

    private Integer code;

    private ResponseCodeEnum codeEnum;

    public StockRuntimeException(ResponseCodeEnum codeEnum) {
        super(codeEnum.getMsg());
        this.codeEnum = codeEnum;
        this.code = codeEnum.getCode();
    }

    public StockRuntimeException(ResponseCodeEnum codeEnum, String msg) {
        super(String.format("%s：[%s]", codeEnum.getMsg(), msg));
        this.codeEnum = codeEnum;
        this.code = codeEnum.getCode();
    }

    public StockRuntimeException(int code, String msg) {
        super(msg);
        this.code = code;
    }

    public StockRuntimeException(String message) {
        super(message);
    }

}
